<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"
    />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./js/lib.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">web 功能部分</a>
            <a>
                <cite>经销商管理</cite>
            </a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form layui-col-md12 x-so">
                <input class="layui-input" placeholder="开始日" name="start" id="start">
                <input class="layui-input" placeholder="截止日" name="end" id="end">
                <input type="text" name="agtId" placeholder="请输入经销商编号" autocomplete="off" class="layui-input">
                <button class="layui-btn" lay-submit lay-filter="search">
                    <i class="layui-icon">&#xe615;</i>
                </button>
            </form>
        </div>
        <xblock>
            <button class="layui-btn" onclick="x_admin_show('添加经销商','./agent-add.html')">
                <i class="layui-icon"></i>添加</button>
            <span class="x-right" style="line-height:40px">共有数据：<span id="count">0</span> 条</span>
        </xblock>
        <table class="layui-table">
            <thead>
                <tr>
                    <th>
                        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary">
                            <i class="layui-icon">&#xe605;</i>
                        </div>
                    </th>
                    <th>经销商ID</th>
                    <th>经销商编码</th>
                    <th>经销商</th>
                    <th>所在地址</th>
                    <th>联系方式</th>
                    <th>营业时间</th>
                    <th>加入时间</th>
                    <th>创建ADMIN</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody id="agtsList">

            </tbody>
        </table>
        <div class="page">
            <div>
                <a class="prev" href="">&lt;&lt;</a>
                <a class="num" href="">1</a>
                <span class="current">2</span>
                <a class="num" href="">3</a>
                <a class="num" href="">489</a>
                <a class="next" href="">&gt;&gt;</a>
            </div>
        </div>

    </div>
    <script>
        layui.use(['laydate','form', 'layer'], function () {
            var laydate = layui.laydate;
            var layer = layui.layer;
            var form = layui.form;
            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });
            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
            form.on('submit(search)', function (data) {
                //console.log(data.field)
                var agtData = {}
                if(data.field.agtId){
                    agtData['code'] = data.field.agtId
                }
                if(data.field.start){
                    agtData['startT'] = data.field.start + '-00:00:00'
                }
                if(data.field.end){
                    agtData['endT'] = data.field.end + '-23:59:59'
                }
                getAgtList(agtData)
                return false;
            })
            function getAgtList(param) { 
                var loadindex1 = layer.load(1, {
                    shade: [0.5, '#000']
                });
                var agtsList = $('#agtsList');
                agtsList.empty();
                $.ajax({
                    url:bAsEuRl + uRlS.agent,
                    type:'get',
                    data: param,
                    success: function (data) { 
                        if(data.msg.code == 200){
                            //console.log(data.data)
                            var agts = data.data;
                            for(var i = 0; i < agts.length; i++){
                                var tr = '<tr>' +
                                    '                    <td>' +
                                    '                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="xxx">' +
                                    '                            <i class="layui-icon">&#xe605;</i>' +
                                    '                        </div>' +
                                    '                    </td>' +
                                    '                    <td>'+ agts[i].w_agt+'</td>' +
                                    '                    <td>' + agts[i].agt_code +'</td>' +
                                    '                    <td>' + agts[i].agt_name.cn +'</td>' +
                                    '                    <td>' + agts[i].agt_addr.cn +'</td>' +
                                    '                    <td>' + agts[i].agt_phone +'</td>' +
                                    '                    <td>' + agts[i].agt_open_daily +'</td>' +
                                    '                    <td>' + formatTime(agts[i].format_time) +'</td>' +
                                    '                    <td>' + agts[i].create_admin +'</td>' +
                                    '                    <td class="td-status">'+ TranStatus(agts[i].agt_status, '停止' ,'正常')+
                                    '                    </td>' +
                                    '                    <td class="td-manage">' +
                                    '                        <a title="编辑" onclick="x_admin_show(\'编辑\',\'agent-detail.html?agt_code='+ agts[i].agt_code+'\')" href="javascript:;">' +
                                    '                            <i class="layui-icon">&#xe642;</i>' +
                                    '                        </a>' +
                                    '                    </td>' +
                                    '                </tr>';
                                    agtsList.append(tr)
                            }
                            layer.close(loadindex1)
                        }else{
                            layer.close(loadindex1);
                            layer.msg(data.msg.msg, { time: 2000 });
                        }
                     },
                     error: function () {
                         layer.close(loadindex1);
                         layer.msg('系统发生严重错误，请联系维护人员')
                    }
                })
            }
            getAgtList({})


        });
        
        



    </script>
</body>

</html>